﻿@{
    ViewBag.Title = "AddAccountRole";
}

@using EFramework.Web.Framework.Extends;
@model EFramework.Entities.Domain.Account.EDNF_Account_RoleEntity
@section bread
{
       <li><a href="@Url.Action("roles", "Security")">角色管理</a></li>
    <li class="active">角色管理</li>
}
<div class="page-content">
    <div class="page-header">
        <h1>添加用户角色
		@*<small>
            <i class="icon-double-angle-right"></i>
            overview &amp; stats
        </small>*@
        </h1>
    </div>
    <div class="row">
        <div class="col-xs-12">
            @using (Ajax.EFBeginForm("AddAccountRole", "Controlpanel"))
            {
                <input type="hidden" value="@Model.RoleID" name="RoleID" />
                
                <div class="form-group">
                    <label for="RoleName" class="col-sm-3 control-label no-padding-right">角色名称 </label>

                    <div class="col-sm-9">
                        <div class="clearfix">
                            <input type="text" id="RoleName" class="col-xs-12 col-sm-8" name="RoleName" value="@Model.RoleName" placeholder="请输入角色名称">
                        </div>
                    </div>
                </div>
                
                <div class="form-group ">
                    <label for="Description" class="col-sm-3 control-label no-padding-right">角色描述</label>

                    <div class="col-sm-9">
                        <div class="clearfix">
                            <textarea name="Description" id="Description" class="col-xs-12 col-sm-8" placeholder="请输入角色描述">@Model.Description</textarea>
                        </div>
                    </div>
                </div>
                

                <div class="clearfix form-actions">
                    <div class="col-md-offset-3 col-md-9">
                        <button type="submit" class="btn btn-info">
                            <i class="icon-ok bigger-110"></i>
                            保存		
                        </button>
                        &nbsp; &nbsp; &nbsp;			
                    <button type="reset" class="btn">
                        <i class="icon-undo bigger-110"></i>
                        重置
                    </button>
                    </div>
                </div>
            }
        </div>
    </div>
</div>

@section scripts{
    <script>

        function OnSuccess(data) {
            if (data.status == 1) {
                alert("添加成功");
            }
            else {
                alert(data.message);
            }
        }


        $('#myform').validate({
            errorElement: 'div',
            errorClass: 'help-block',
            focusInvalid: false,

            rules: {
                RoleName: {
                    required: true
                }
            },
            messages: {
                RoleName: {
                    required: "角色名称不能为空."
                }
            },

            highlight: function (e) {
                $(e).parents('.form-group').removeClass('has-info').addClass('has-error');
            },

            unhighlight: function (e) {
                $(e).closest('.form-group').removeClass('has-error').addClass('has-info');
                $(e).parents('.form-group').removeClass('has-error').addClass('has-info');
                //$(e).remove();
            },

            errorPlacement: function (error, element) {

                //if (element.is(':checkbox') || element.is(':radio')) {
                //    var controls = element.closest('div[class*="col-"]');
                //    if (controls.find(':checkbox,:radio').length > 1) controls.append(error);
                //    else error.insertAfter(element.nextAll('.lbl:eq(0)').eq(0));
                //}
                //else if (element.is('.select2')) {
                //    error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
                //}
                //else if (element.is('.chosen-select')) {
                //    error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
                //}
                //else
                //    error.insertAfter(element.parent());

                error.appendTo(element.parents('.col-sm-9'));
            }
            
        });



    </script>
}
